﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace Chenxin.Lib.House.BLL
{
    /// <summary>
    /// 业务逻辑类House_CommunityLogs 的摘要说明。
    /// </summary>
    public class House_CommunityLogs
    {
        public House_CommunityLogs()
        { }
        #region  成员方法
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Chenxin.Lib.House.Entity.House_CommunityLogs model)
        {
            Chenxin.Lib.House.DAL.House_CommunityLogs.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Chenxin.Lib.House.Entity.House_CommunityLogs model)
        {
            Chenxin.Lib.House.DAL.House_CommunityLogs.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Delete(Guid RecordId)
        {

            Chenxin.Lib.House.DAL.House_CommunityLogs.Delete(RecordId);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Chenxin.Lib.House.Entity.House_CommunityLogs GetModel(Guid RecordId)
        {

            return Chenxin.Lib.House.DAL.House_CommunityLogs.GetModel(RecordId);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return Chenxin.Lib.House.DAL.House_CommunityLogs.GetList(strWhere);
        }
        
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Chenxin.Lib.House.Entity.House_CommunityLogs> GetModelList(string strWhere)
        {
            DataSet ds = Chenxin.Lib.House.DAL.House_CommunityLogs.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Chenxin.Lib.House.Entity.House_CommunityLogs> DataTableToList(DataTable dt)
        {
            List<Chenxin.Lib.House.Entity.House_CommunityLogs> modelList = new List<Chenxin.Lib.House.Entity.House_CommunityLogs>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Chenxin.Lib.House.Entity.House_CommunityLogs model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Chenxin.Lib.House.Entity.House_CommunityLogs();
                    if (dt.Rows[n]["RecordId"].ToString() != "")
                    {
                        model.RecordId = new Guid(dt.Rows[n]["RecordId"].ToString());
                    }
                    if (dt.Rows[n]["UserId"].ToString() != "")
                    {
                        model.UserId = new Guid(dt.Rows[n]["UserId"].ToString());
                    }
                    model.UserName = dt.Rows[n]["UserName"].ToString();
                    if (dt.Rows[n]["DepartId"].ToString() != "")
                    {
                        model.DepartId = new Guid(dt.Rows[n]["DepartId"].ToString());
                    }
                    model.DepartName = dt.Rows[n]["DepartName"].ToString();
                    if (dt.Rows[n]["CityId"].ToString() != "")
                    {
                        model.CityId = new Guid(dt.Rows[n]["CityId"].ToString());
                    }
                    model.CityName = dt.Rows[n]["CityName"].ToString();
                    if (dt.Rows[n]["CompanyId"].ToString() != "")
                    {
                        model.CompanyId = new Guid(dt.Rows[n]["CompanyId"].ToString());
                    }
                    model.CompanyName = dt.Rows[n]["CompanyName"].ToString();
                    model.OprType = dt.Rows[n]["OprType"].ToString();
                    model.OperationContext = dt.Rows[n]["OperationContext"].ToString();
                    if (dt.Rows[n]["Addtime"].ToString() != "")
                    {
                        model.Addtime = DateTime.Parse(dt.Rows[n]["Addtime"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        //*******************************************
        //功能概要       ：根据参数列表获得用户信息一览
        //参数説明       ：hsParams 参数列表
        //返回值説明     ：无
        //功能詳細       ：根据参数列表获得用户信息一览
        //作成者         ：zou.xiaochun
        //作成日         ：2010-09-28
        //*******************************************
        public DataSet GetModelListByCoditions(string strWhere, int strPageIndex, int strPageSize)
        {
            //排序
            string strOrderField = " Addtime desc";
            //欲选择字段列表 
            string FieldList = " RecordId,UserId,UserName,DepartId,DepartName,CityId,CityName,CompanyId,CompanyName,OprType,OperationContext,Addtime ";
            //子查询欲选择字段列表
            StringBuilder sb = new StringBuilder();
            sb.Append(" RecordId,UserId,UserName,DepartId,DepartName,CityId,CityName,CompanyId,CompanyName,OprType,OperationContext,Addtime ");
            //所要查询的表名
            string TableName = " House_CommunityLogs ";
            return Chenxin.Lib.House.DAL.House_CommunityLogs.GetList(strPageIndex, strPageSize, strOrderField, TableName, strWhere, FieldList, sb.ToString(), true);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        #endregion  成员方法
    }
}
